package pl.edu.agh.sius.model;

import java.io.File;

import javax.faces.model.SelectItem;

import pl.edu.agh.sius.controller.InputFileController;

public class EstateSplitRequestBB implements ConcernBB {

	protected final EstateSplitRequest esr = new EstateSplitRequest();

	public String getAddress() {
		return esr.getAddress();
	}

	public String getCadastreDocURL() {
		return esr.getCadastreDocURL();
	}

	public String getEstateSplitPetitionDocURL() {
		return esr.getEstateSplitPetitionDocURL();
	}

	public String getFirstName() {
		return esr.getFirstName();
	}

	public String getLocalSpatialPlanDocURL() {
		return esr.getLocalSpatialPlanDocURL();
	}

	public String getPesel() {
		return esr.getPesel();
	}

	public String getPropertyOwnershipDocURL() {
		return esr.getPropertyOwnershipDocURL();
	}

	public String getSurname() {
		return esr.getSurname();
	}

	public void setAddress(String address) {
		esr.setAddress(address);
	}

	public void setCadastreDocURL(String cadastreDocURL) {
		esr.setCadastreDocURL(cadastreDocURL);
	}

	public void setEstateSplitPetitionDocURL(String estateSplitPetitionDocURL) {
		esr.setEstateSplitPetitionDocURL(estateSplitPetitionDocURL);
	}

	public void setFirstName(String firstName) {
		esr.setFirstName(firstName);
	}

	public void setLocalSpatialPlanDocURL(String localSpatialPlanDocURL) {
		esr.setLocalSpatialPlanDocURL(localSpatialPlanDocURL);
	}

	public void setPesel(String pesel) {
		esr.setPesel(pesel);
	}

	public void setPropertyOwnershipDocURL(String propertyOwnershipDocURL) {
		esr.setPropertyOwnershipDocURL(propertyOwnershipDocURL);
	}

	public void setSurname(String surname) {
		esr.setSurname(surname);
	}

	public static final String ESTATE_SPLIT_PETITION = "Wniosek o podział nieruchomości", PROPERTY_OWNERSHIP = "Zaświadczenie o prawie własności",
			CADASTRE = "Kataster", LOCAL_SPATIAL_PLAN = "Plan zagospodarowania powierzchniowego";

	private static String[] formalDocumentNames = new String[] {
			ESTATE_SPLIT_PETITION,
			LOCAL_SPATIAL_PLAN,
			CADASTRE,
			PROPERTY_OWNERSHIP};

	public SelectItem[] getFormalDocumentsNames() {
		SelectItem[] items = new SelectItem[formalDocumentNames.length];
		for (int i = 0; i < formalDocumentNames.length; ++i) {
			items[i] = new SelectItem(formalDocumentNames[i]);
		}
		return items;
	}

	public boolean areAttachementsValid(InputFileController ifc) {
		if (ifc.getFileList().size() != formalDocumentNames.length) {
			return false;
		}
		for (InputFileData ifd1 : ifc.getFileList()) {
			if (ifd1.getFileFormalName() == null) {
				return false;
			}
			for (InputFileData ifd2 : ifc.getFileList()) {
				if (!ifd1.equals(ifd2)) {
					if (ifd1.getFileFormalName().equals(
							ifd2.getFileFormalName())) {
						return false;
					}
				}
			}
		}
		return true;
	}

	private File estateSplitPetitionFile, propertyOwnershipFile, cadastreFile,
			localSpatialPlanFile;

	public File getEstateSplitPetitionFile() {
		return estateSplitPetitionFile;
	}

	public void setEstateSplitPetitionFile(File estateSplitPetitionFile) {
		this.estateSplitPetitionFile = estateSplitPetitionFile;
	}

	public File getPropertyOwnershipFile() {
		return propertyOwnershipFile;
	}

	public void setPropertyOwnershipFile(File propertyOwnershipFile) {
		this.propertyOwnershipFile = propertyOwnershipFile;
	}

	public File getCadastreFile() {
		return cadastreFile;
	}

	public void setCadastreFile(File cadastreFile) {
		this.cadastreFile = cadastreFile;
	}

	public File getLocalSpatialPlanFile() {
		return localSpatialPlanFile;
	}

	public void setLocalSpatialPlanFile(File localSpatialPlanFile) {
		this.localSpatialPlanFile = localSpatialPlanFile;
	}

	
	private boolean agreement = false;

	public boolean isAgreement() {
		return agreement;
	}

	public void setAgreement(boolean agreement) {
		this.agreement = agreement;
	}

}
